<!DOCTYPE HTML>
<html lang="zh-tw" >
    <!-- Start book python高级 -->
    <head>
        <!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>数据库设计 | python高级</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-splitter/splitter.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-emphasize/plugin.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../day16/pymysql.html" />
    
    
    <link rel="prev" href="../day16/sql_code.html" />
    

        <!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
        
    <div class="book"
        data-level="6.3"
        data-chapter-title="数据库设计"
        data-filepath="day16/dbdesign.md"
        data-basepath=".."
        data-revision="Wed Sep 26 2018 22:46:13 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Python高级
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="day11/00.readme.html">
            
                
                    <a href="../day11/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        Python语法高级专题1
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="day11/01.GIL.html">
            
                
                    <a href="../day11/01.GIL.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        GIL问题
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="day11/02.copy.html">
            
                
                    <a href="../day11/02.copy.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        赋值-浅拷贝-深拷贝
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="day11/03.import.html">
            
                
                    <a href="../day11/03.import.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        import导入模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="day11/04.review.html">
            
                
                    <a href="../day11/04.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="day12/00.readme.html">
            
                
                    <a href="../day12/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        Python语法高级专题2
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="day12/01.mro.html">
            
                
                    <a href="../day12/01.mro.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        多继承和MRO顺序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="day12/02.property.html">
            
                
                    <a href="../day12/02.property.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        property属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="day12/03.magic.html">
            
                
                    <a href="../day12/03.magic.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        魔法属性和方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="day12/04.with.html">
            
                
                    <a href="../day12/04.with.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        with管理上下文
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="day12/05.review.html">
            
                
                    <a href="../day12/05.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="day13/00.readme.html">
            
                
                    <a href="../day13/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        Python语法之装饰器
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="day13/01.closure.html">
            
                
                    <a href="../day13/01.closure.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        闭包
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="day13/02.decorator.html">
            
                
                    <a href="../day13/02.decorator.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        装饰器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="day13/03.review.html">
            
                
                    <a href="../day13/03.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="day14/00.readme.html">
            
                
                    <a href="../day14/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        MySQL数据库基本操作
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="day14/01.数据库概述.html">
            
                
                    <a href="../day14/01.数据库概述.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        数据库概述
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="day14/02.数据类型和约束.html">
            
                
                    <a href="../day14/02.数据类型和约束.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        数据完整性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="day14/03.Navicat.html">
            
                
                    <a href="../day14/03.Navicat.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        图形化客户端Navicat
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="day14/04.命令行客户端.html">
            
                
                    <a href="../day14/04.命令行客户端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        命令行客户端SQL的使用
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.1" data-path="day14/05.sql_con.html">
            
                
                    <a href="../day14/05.sql_con.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.1.</b>
                        
                        登录和退出数据库
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.2" data-path="day14/07.sql_table_struct.html">
            
                
                    <a href="../day14/07.sql_table_struct.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.2.</b>
                        
                        表结构的操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.3" data-path="day14/06.sql_database.html">
            
                
                    <a href="../day14/06.sql_database.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.3.</b>
                        
                        数据库的操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.4" data-path="day14/08.表数据操作.html">
            
                
                    <a href="../day14/08.表数据操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.4.</b>
                        
                        表数据的操作
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="day14/09.review.html">
            
                
                    <a href="../day14/09.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        知识总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="day15/00.readme.html">
            
                
                    <a href="../day15/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        MYSQL数据库进阶操作
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="day15/01.练习.html">
            
                
                    <a href="../day15/01.练习.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        练习强化
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="day15/02.where条件.html">
            
                
                    <a href="../day15/02.where条件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        条件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="day15/03.排序查询.html">
            
                
                    <a href="../day15/03.排序查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="day15/04.分页查询.html">
            
                
                    <a href="../day15/04.分页查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        分页
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="day15/05.聚合函数.html">
            
                
                    <a href="../day15/05.聚合函数.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        聚合函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="day15/06.分组.html">
            
                
                    <a href="../day15/06.分组.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        分组
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="day15/07.连接.html">
            
                
                    <a href="../day15/07.连接.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        连接
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="day15/08.自连接.html">
            
                
                    <a href="../day15/08.自连接.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.</b>
                        
                        自连接
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.9" data-path="day15/09.子查询.html">
            
                
                    <a href="../day15/09.子查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.9.</b>
                        
                        子查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.10" data-path="day15/10.总结.html">
            
                
                    <a href="../day15/10.总结.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.10.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="day16/readme.html">
            
                
                    <a href="../day16/readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        MYSQL数据库编程
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="day16/data.html">
            
                
                    <a href="../day16/data.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        数据准备
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="day16/sql_code.html">
            
                
                    <a href="../day16/sql_code.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        SQL演练
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="6.3" data-path="day16/dbdesign.html">
            
                
                    <a href="../day16/dbdesign.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        数据库设计
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="day16/pymysql.html">
            
                
                    <a href="../day16/pymysql.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        数据库编程
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="day16/zongjie.html">
            
                
                    <a href="../day16/zongjie.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="day17/00.readme.html">
            
                
                    <a href="../day17/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        MySQL数据库高级用法
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="day17/01.view.html">
            
                
                    <a href="../day17/01.view.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        视图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="day17/02.transaction.html">
            
                
                    <a href="../day17/02.transaction.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        事务
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="day17/03.sql_index.html">
            
                
                    <a href="../day17/03.sql_index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.3.</b>
                        
                        索引
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4" data-path="day17/04.user.html">
            
                
                    <a href="../day17/04.user.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.</b>
                        
                        用户管理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5" data-path="day17/05.master_slave.html">
            
                
                    <a href="../day17/05.master_slave.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.</b>
                        
                        主从配置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.6" data-path="day17/06.review.html">
            
                
                    <a href="../day17/06.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="8" data-path="day18/00.readme.html">
            
                
                    <a href="../day18/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        miniweb框架
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="day18/01.框架是什么.html">
            
                
                    <a href="../day18/01.框架是什么.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        框架概念
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="day18/02.实现框架.html">
            
                
                    <a href="../day18/02.实现框架.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        实现一个简单的框架
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="day18/03.模板.html">
            
                
                    <a href="../day18/03.模板.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        模板替换
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="day18/04.路由.html">
            
                
                    <a href="../day18/04.路由.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.4.</b>
                        
                        路由概念
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.5" data-path="day18/05.显示股票数据.html">
            
                
                    <a href="../day18/05.显示股票数据.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.5.</b>
                        
                        股票收藏夹
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.6" data-path="day18/05.review.html">
            
                
                    <a href="../day18/05.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.6.</b>
                        
                        复习
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    本書使用 GitBook 釋出
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >python高级</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x6570;&#x636E;&#x5E93;&#x7684;&#x8BBE;&#x8BA1;">&#x6570;&#x636E;&#x5E93;&#x7684;&#x8BBE;&#x8BA1;</h1>
<h2 id="31-&#x5B66;&#x4E60;&#x76EE;&#x6807;">3.1 &#x5B66;&#x4E60;&#x76EE;&#x6807;</h2>
<ul>
<li>&#x4E86;&#x89E3;E-R&#x6A21;&#x578B;&#x7684;&#x7EC4;&#x6210;&#x90E8;&#x5206;</li>
<li>&#x80FD;&#x591F;&#x4E3E;&#x4F8B;&#x8BF4;&#x51FA;&#x751F;&#x6D3B;&#x4E2D; 1&#x5BF9;1 1&#x5BF9;&#x591A; &#x591A;&#x5BF9;&#x591A;&#x5173;&#x7CFB;&#x7684;&#x4F8B;&#x5B50;</li>
<li>&#x77E5;&#x9053;&#x4E00;&#x4E2A;&#x8868;&#x7ED3;&#x6784;&#x8BBE;&#x8BA1;&#x662F;&#x5426;&#x6EE1;&#x8DB3;&#x8303;&#x5F0F;&#x7684;&#x8981;&#x6C42;</li>
</ul>
<h2 id="32-sql&#x6F14;&#x7EC3;&#x4E2D;&#x6240;&#x6709;&#x7684;&#x8868;">3.2 SQL&#x6F14;&#x7EC3;&#x4E2D;&#x6240;&#x6709;&#x7684;&#x8868;</h2>
<p><img src="../assets/day16/&#x8BA2;&#x5355;&#x6570;&#x636E;&#x8868;&#x8BBE;&#x8BA1;.png" alt=""></p>
<h3 id="&#x521B;&#x5EFA;-&#x5546;&#x54C1;&#x5206;&#x7C7B;-&#x8868;&#x4E4B;&#x524D;&#x5DF2;&#x7ECF;&#x521B;&#x5EFA;&#x65E0;&#x9700;&#x518D;&#x6B21;&#x521B;&#x5EFA;">&#x521B;&#x5EFA; &quot;&#x5546;&#x54C1;&#x5206;&#x7C7B;&quot; &#x8868;(&#x4E4B;&#x524D;&#x5DF2;&#x7ECF;&#x521B;&#x5EFA;,&#x65E0;&#x9700;&#x518D;&#x6B21;&#x521B;&#x5EFA;)</h3>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span> goods_cates(
    <span class="hljs-keyword">id</span> <span class="hljs-built_in">int</span> <span class="hljs-keyword">unsigned</span> primary <span class="hljs-keyword">key</span> auto_increment <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    <span class="hljs-keyword">name</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">40</span>) <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>
);</span>
</code></pre>
<h3 id="&#x521B;&#x5EFA;-&#x5546;&#x54C1;&#x54C1;&#x724C;-&#x8868;&#x4E4B;&#x524D;&#x5DF2;&#x7ECF;&#x521B;&#x5EFA;&#x65E0;&#x9700;&#x518D;&#x6B21;&#x521B;&#x5EFA;">&#x521B;&#x5EFA; &quot;&#x5546;&#x54C1;&#x54C1;&#x724C;&quot; &#x8868;(&#x4E4B;&#x524D;&#x5DF2;&#x7ECF;&#x521B;&#x5EFA;,&#x65E0;&#x9700;&#x518D;&#x6B21;&#x521B;&#x5EFA;)</h3>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span> goods_brands (
    <span class="hljs-keyword">id</span> <span class="hljs-built_in">int</span> <span class="hljs-keyword">unsigned</span> primary <span class="hljs-keyword">key</span> auto_increment <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    <span class="hljs-keyword">name</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">40</span>) <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>
);</span>
</code></pre>
<h3 id="&#x521B;&#x5EFA;-&#x5546;&#x54C1;-&#x8868;&#x4E4B;&#x524D;&#x5DF2;&#x7ECF;&#x521B;&#x5EFA;&#x65E0;&#x9700;&#x518D;&#x6B21;&#x521B;&#x5EFA;">&#x521B;&#x5EFA; &quot;&#x5546;&#x54C1;&quot; &#x8868;(&#x4E4B;&#x524D;&#x5DF2;&#x7ECF;&#x521B;&#x5EFA;,&#x65E0;&#x9700;&#x518D;&#x6B21;&#x521B;&#x5EFA;)</h3>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span> goods(
    <span class="hljs-keyword">id</span> <span class="hljs-built_in">int</span> <span class="hljs-keyword">unsigned</span> primary <span class="hljs-keyword">key</span> auto_increment <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    <span class="hljs-keyword">name</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">40</span>) <span class="hljs-keyword">default</span> <span class="hljs-string">&apos;&apos;</span>,
    price <span class="hljs-built_in">decimal</span>(<span class="hljs-number">5</span>,<span class="hljs-number">2</span>),
    cate_id <span class="hljs-built_in">int</span> <span class="hljs-keyword">unsigned</span>,
    brand_id <span class="hljs-built_in">int</span> <span class="hljs-keyword">unsigned</span>,
    is_show <span class="hljs-built_in">bit</span> <span class="hljs-keyword">default</span> <span class="hljs-number">1</span>,
    is_saleoff <span class="hljs-built_in">bit</span> <span class="hljs-keyword">default</span> <span class="hljs-number">0</span>,
    foreign <span class="hljs-keyword">key</span>(cate_id) <span class="hljs-keyword">references</span> goods_cates(<span class="hljs-keyword">id</span>),
    foreign <span class="hljs-keyword">key</span>(brand_id) <span class="hljs-keyword">references</span> goods_brands(<span class="hljs-keyword">id</span>)
);</span>
</code></pre>
<h3 id="&#x521B;&#x5EFA;-&#x987E;&#x5BA2;-&#x8868;">&#x521B;&#x5EFA; &quot;&#x987E;&#x5BA2;&quot; &#x8868;</h3>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span> customer(
    <span class="hljs-keyword">id</span> <span class="hljs-built_in">int</span> <span class="hljs-keyword">unsigned</span> auto_increment primary <span class="hljs-keyword">key</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    <span class="hljs-keyword">name</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">30</span>) <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    addr <span class="hljs-built_in">varchar</span>(<span class="hljs-number">100</span>),
    tel <span class="hljs-built_in">varchar</span>(<span class="hljs-number">11</span>) <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>
);</span>
</code></pre>
<h3 id="&#x521B;&#x5EFA;-&#x8BA2;&#x5355;-&#x8868;">&#x521B;&#x5EFA; &quot;&#x8BA2;&#x5355;&quot; &#x8868;</h3>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span> orders(
    <span class="hljs-keyword">id</span> <span class="hljs-built_in">int</span> <span class="hljs-keyword">unsigned</span> auto_increment primary <span class="hljs-keyword">key</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    order_date_time datetime <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    customer_id <span class="hljs-built_in">int</span> <span class="hljs-keyword">unsigned</span>,
    foreign <span class="hljs-keyword">key</span>(customer_id) <span class="hljs-keyword">references</span> customer(<span class="hljs-keyword">id</span>)
);</span>
</code></pre>
<h3 id="&#x521B;&#x5EFA;-&#x8BA2;&#x5355;&#x8BE6;&#x60C5;-&#x8868;">&#x521B;&#x5EFA; &quot;&#x8BA2;&#x5355;&#x8BE6;&#x60C5;&quot; &#x8868;</h3>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span> order_detail(
    <span class="hljs-keyword">id</span> <span class="hljs-built_in">int</span> <span class="hljs-keyword">unsigned</span> auto_increment primary <span class="hljs-keyword">key</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    order_id <span class="hljs-built_in">int</span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    goods_id <span class="hljs-built_in">int</span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    quantity tinyint <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    foreign <span class="hljs-keyword">key</span>(order_id) <span class="hljs-keyword">references</span> orders(<span class="hljs-keyword">id</span>),
    foreign <span class="hljs-keyword">key</span>(goods_id) <span class="hljs-keyword">references</span> goods(<span class="hljs-keyword">id</span>)
);</span>
</code></pre>
<h2 id="&#x8BF4;&#x660E;">&#x8BF4;&#x660E;</h2>
<ul>
<li>&#x4EE5;&#x4E0A;&#x521B;&#x5EFA;&#x8868;&#x7684;&#x987A;&#x5E8F;&#x662F;&#x6709;&#x8981;&#x6C42;&#x7684;,&#x5373;&#x5982;&#x679C;goods&#x8868;&#x4E2D;&#x7684;&#x5916;&#x952E;&#x7EA6;&#x675F;&#x7528;&#x7684;&#x662F;goods_cates&#x6216;&#x8005;&#x662F;goods_brands,&#x90A3;&#x4E48;&#x5C31;&#x5E94;&#x8BE5;&#x5148;&#x521B;&#x5EFA;&#x8FD9;2&#x4E2A;&#x8868;,&#x5426;&#x5219;&#x521B;&#x5EFA;goods&#x4F1A;&#x5931;&#x8D25;</li>
<li>&#x521B;&#x5EFA;&#x5916;&#x952E;&#x65F6;,&#x4E00;&#x5B9A;&#x8981;&#x6CE8;&#x610F;&#x7C7B;&#x578B;&#x8981;&#x76F8;&#x540C;,&#x5426;&#x5219;&#x5931;&#x8D25;</li>
</ul>
<h2 id="33-&#x4E09;&#x8303;&#x5F0F;">3.3 &#x4E09;&#x8303;&#x5F0F;</h2>
<ul>
<li>&#x7ECF;&#x8FC7;&#x7814;&#x7A76;&#x548C;&#x5BF9;&#x4F7F;&#x7528;&#x4E2D;&#x95EE;&#x9898;&#x7684;&#x603B;&#x7ED3;&#xFF0C;&#x5BF9;&#x4E8E;&#x8BBE;&#x8BA1;&#x6570;&#x636E;&#x5E93;&#x63D0;&#x51FA;&#x4E86;&#x4E00;&#x4E9B;&#x89C4;&#x8303;&#xFF0C;&#x8FD9;&#x4E9B;&#x89C4;&#x8303;&#x88AB;&#x79F0;&#x4E3A;&#x8303;&#x5F0F;(Normal Form)</li>
<li><p>&#x76EE;&#x524D;&#x6709;&#x8FF9;&#x53EF;&#x5BFB;&#x7684;&#x5171;&#x6709;8&#x79CD;&#x8303;&#x5F0F;&#xFF0C;&#x4E00;&#x822C;&#x9700;&#x8981;&#x9075;&#x5B88;3&#x8303;&#x5F0F;&#x5373;&#x53EF;</p>
</li>
<li><p><strong>&#x7B2C;&#x4E00;&#x8303;&#x5F0F;&#xFF08;1NF&#xFF09;</strong>&#xFF1A;&#x5F3A;&#x8C03;&#x7684;&#x662F;&#x5217;&#x7684;&#x539F;&#x5B50;&#x6027;&#xFF0C;&#x5373;&#x5217;&#x4E0D;&#x80FD;&#x591F;&#x518D;&#x5206;&#x6210;&#x5176;&#x4ED6;&#x51E0;&#x5217;&#x3002; </p>
<blockquote>
<p>&#x8003;&#x8651;&#x8FD9;&#x6837;&#x4E00;&#x4E2A;&#x8868;&#xFF1A;&#x3010;&#x8054;&#x7CFB;&#x4EBA;&#x3011;&#xFF08;&#x59D3;&#x540D;&#xFF0C;&#x6027;&#x522B;&#xFF0C;&#x7535;&#x8BDD;&#xFF09;</p>
</blockquote>
</li>
</ul>
<blockquote>
<p>&#x5982;&#x679C;&#x5728;&#x5B9E;&#x9645;&#x573A;&#x666F;&#x4E2D;&#xFF0C;&#x4E00;&#x4E2A;&#x8054;&#x7CFB;&#x4EBA;&#x6709;&#x5BB6;&#x5EAD;&#x7535;&#x8BDD;&#x548C;&#x516C;&#x53F8;&#x7535;&#x8BDD;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x79CD;&#x8868;&#x7ED3;&#x6784;&#x8BBE;&#x8BA1;&#x5C31;&#x6CA1;&#x6709;&#x8FBE;&#x5230; 1NF&#x3002;&#x8981;&#x7B26;&#x5408; 1NF &#x6211;&#x4EEC;&#x53EA;&#x9700;&#x628A;&#x5217;&#xFF08;&#x7535;&#x8BDD;&#xFF09;&#x62C6;&#x5206;&#xFF0C;&#x5373;&#xFF1A;&#x3010;&#x8054;&#x7CFB;&#x4EBA;&#x3011;&#xFF08;&#x59D3;&#x540D;&#xFF0C;&#x6027;&#x522B;&#xFF0C;&#x5BB6;&#x5EAD;&#x7535;&#x8BDD;&#xFF0C;&#x516C;&#x53F8;&#x7535;&#x8BDD;&#xFF09;&#x3002;1NF &#x5F88;&#x597D;&#x8FA8;&#x522B;&#xFF0C;&#x4F46;&#x662F; 2NF &#x548C; 3NF &#x5C31;&#x5BB9;&#x6613;&#x641E;&#x6DF7;&#x6DC6;&#x3002; </p>
</blockquote>
<p><img src="../assets/day16/1nf.png" alt=""></p>
<ul>
<li><strong>&#x7B2C;&#x4E8C;&#x8303;&#x5F0F;&#xFF08;2NF&#xFF09;</strong>&#xFF1A;&#x9996;&#x5148;&#x662F; 1NF&#xFF0C;&#x53E6;&#x5916;&#x5305;&#x542B;&#x4E24;&#x90E8;&#x5206;&#x5185;&#x5BB9;&#xFF0C;&#x4E00;&#x662F;&#x8868;&#x5FC5;&#x987B;&#x6709;&#x4E00;&#x4E2A;&#x4E3B;&#x952E;&#xFF1B;&#x4E8C;&#x662F;&#x975E;&#x4E3B;&#x952E;&#x5B57;&#x6BB5; &#x5FC5;&#x987B;&#x5B8C;&#x5168;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#xFF0C;&#x800C;&#x4E0D;&#x80FD;&#x53EA;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#x7684;&#x4E00;&#x90E8;&#x5206;&#x3002; </li>
</ul>
<blockquote>
<p>&#x8003;&#x8651;&#x4E00;&#x4E2A;&#x8BA2;&#x5355;&#x660E;&#x7EC6;&#x8868;&#xFF1A;&#x3010;OrderDetail&#x3011;&#xFF08;OrderID&#xFF0C;ProductID&#xFF0C;UnitPrice&#xFF0C;Discount&#xFF0C;Quantity&#xFF0C;ProductName&#xFF09;&#x3002; </p>
</blockquote>
<p>&#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x77E5;&#x9053;&#x5728;&#x4E00;&#x4E2A;&#x8BA2;&#x5355;&#x4E2D;&#x53EF;&#x4EE5;&#x8BA2;&#x8D2D;&#x591A;&#x79CD;&#x4EA7;&#x54C1;&#xFF0C;&#x6240;&#x4EE5;&#x5355;&#x5355;&#x4E00;&#x4E2A; OrderID &#x662F;&#x4E0D;&#x8DB3;&#x4EE5;&#x6210;&#x4E3A;&#x4E3B;&#x952E;&#x7684;&#xFF0C;&#x4E3B;&#x952E;&#x5E94;&#x8BE5;&#x662F;&#xFF08;OrderID&#xFF0C;ProductID&#xFF09;&#x3002;&#x663E;&#x800C;&#x6613;&#x89C1; Discount&#xFF08;&#x6298;&#x6263;&#xFF09;&#xFF0C;Quantity&#xFF08;&#x6570;&#x91CF;&#xFF09;&#x5B8C;&#x5168;&#x4F9D;&#x8D56;&#xFF08;&#x53D6;&#x51B3;&#xFF09;&#x4E8E;&#x4E3B;&#x952E;&#xFF08;OderID&#xFF0C;ProductID&#xFF09;&#xFF0C;&#x800C; UnitPrice&#x5355;&#x4EF7;&#xFF0C;ProductName&#x4EA7;&#x54C1;&#x540D;&#x79F0; &#x53EA;&#x4F9D;&#x8D56;&#x4E8E; ProductID&#x3002;&#x6240;&#x4EE5; OrderDetail &#x8868;&#x4E0D;&#x7B26;&#x5408; 2NF&#x3002;&#x4E0D;&#x7B26;&#x5408; 2NF &#x7684;&#x8BBE;&#x8BA1;&#x5BB9;&#x6613;&#x4EA7;&#x751F;&#x5197;&#x4F59;&#x6570;&#x636E;&#x3002; </p>
<p><img src="../assets/day16/2nf.png" alt=""></p>
<blockquote>
<p>&#x53EF;&#x4EE5;&#x628A;&#x3010;OrderDetail&#x3011;&#x8868;&#x62C6;&#x5206;&#x4E3A;&#x3010;OrderDetail&#x3011;&#xFF08;OrderID&#xFF0C;ProductID&#xFF0C;Discount&#xFF0C;Quantity&#xFF09;&#x548C;&#x3010;Product&#x3011;&#xFF08;ProductID&#xFF0C;UnitPrice&#xFF0C;ProductName&#xFF09;&#x6765;&#x6D88;&#x9664;&#x539F;&#x8BA2;&#x5355;&#x8868;&#x4E2D;UnitPrice&#xFF0C;ProductName&#x591A;&#x6B21;&#x91CD;&#x590D;&#x7684;&#x60C5;&#x51B5;&#x3002; </p>
</blockquote>
<ul>
<li><strong>&#x7B2C;&#x4E09;&#x8303;&#x5F0F;&#xFF08;3NF&#xFF09;</strong>&#xFF1A;&#x9996;&#x5148;&#x662F; 2NF&#xFF0C;&#x53E6;&#x5916;&#x975E;&#x4E3B;&#x952E;&#x5217;&#x5FC5;&#x987B;&#x76F4;&#x63A5;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#xFF0C;&#x4E0D;&#x80FD;&#x5B58;&#x5728;&#x4F20;&#x9012;&#x4F9D;&#x8D56;&#x3002;&#x5373;&#x4E0D;&#x80FD;&#x5B58;&#x5728;&#xFF1A;&#x975E;&#x4E3B;&#x952E;&#x5217; A &#x4F9D;&#x8D56;&#x4E8E;&#x975E;&#x4E3B;&#x952E;&#x5217; B&#xFF0C;&#x975E;&#x4E3B;&#x952E;&#x5217; B &#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#x7684;&#x60C5;&#x51B5;&#x3002; </li>
</ul>
<blockquote>
<p>&#x8003;&#x8651;&#x4E00;&#x4E2A;&#x8BA2;&#x5355;&#x8868;&#x3010;Order&#x3011;&#xFF08;OrderID&#xFF0C;OrderDate&#xFF0C;CustomerID&#xFF0C;CustomerName&#xFF0C;CustomerAddr&#xFF0C;CustomerCity&#xFF09;&#x4E3B;&#x952E;&#x662F;&#xFF08;OrderID&#xFF09;&#x3002; 
&#x5176;&#x4E2D; OrderDate&#xFF0C;CustomerID&#xFF0C;CustomerName&#xFF0C;CustomerAddr&#xFF0C;CustomerCity &#x7B49;&#x975E;&#x4E3B;&#x952E;&#x5217;&#x90FD;&#x5B8C;&#x5168;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#xFF08;OrderID&#xFF09;&#xFF0C;&#x6240;&#x4EE5;&#x7B26;&#x5408; 2NF&#x3002;&#x4E0D;&#x8FC7;&#x95EE;&#x9898;&#x662F; CustomerName&#xFF0C;CustomerAddr&#xFF0C;CustomerCity &#x76F4;&#x63A5;&#x4F9D;&#x8D56;&#x7684;&#x662F; CustomerID&#xFF08;&#x975E;&#x4E3B;&#x952E;&#x5217;&#xFF09;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x76F4;&#x63A5;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#xFF0C;&#x5B83;&#x662F;&#x901A;&#x8FC7;&#x4F20;&#x9012;&#x624D;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x7B26;&#x5408; 3NF&#x3002; </p>
</blockquote>
<p><img src="../assets/day16/3nf.png" alt=""></p>
<blockquote>
<p>&#x901A;&#x8FC7;&#x62C6;&#x5206;&#x3010;Order&#x3011;&#x4E3A;&#x3010;Order&#x3011;&#xFF08;OrderID&#xFF0C;OrderDate&#xFF0C;CustomerID&#xFF09;&#x548C;&#x3010;Customer&#x3011;&#xFF08;CustomerID&#xFF0C;CustomerName&#xFF0C;CustomerAddr&#xFF0C;CustomerCity&#xFF09;&#x4ECE;&#x800C;&#x8FBE;&#x5230; 3NF&#x3002;</p>
</blockquote>
<p>*&#x7B2C;&#x4E8C;&#x8303;&#x5F0F;&#xFF08;2NF&#xFF09;&#x548C;&#x7B2C;&#x4E09;&#x8303;&#x5F0F;&#xFF08;3NF&#xFF09;&#x7684;&#x6982;&#x5FF5;&#x5F88;&#x5BB9;&#x6613;&#x6DF7;&#x6DC6;&#xFF0C;&#x533A;&#x5206;&#x5B83;&#x4EEC;&#x7684;&#x5173;&#x952E;&#x70B9;&#x5728;&#x4E8E;&#xFF0C;2NF&#xFF1A;&#x975E;&#x4E3B;&#x952E;&#x5217;&#x662F;&#x5426;&#x5B8C;&#x5168;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#xFF0C;&#x8FD8;&#x662F;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF1B;3NF&#xFF1A;&#x975E;&#x4E3B;&#x952E;&#x5217;&#x662F;&#x76F4;&#x63A5;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#xFF0C;&#x8FD8;&#x662F;&#x76F4;&#x63A5;&#x4F9D;&#x8D56;&#x4E8E;&#x975E;&#x4E3B;&#x952E;&#x5217;&#x3002;</p>
<h3 id="&#x6700;&#x7EC8;&#x8868;">&#x6700;&#x7EC8;&#x8868;</h3>
<p><img src="../assets/day16/3nf.png" alt=""></p>
<h2 id="34-er&#x6A21;&#x578B;">3.4 E-R&#x6A21;&#x578B;</h2>
<h3 id="341-er&#x6A21;&#x578B;&#x7B80;&#x4ECB;">3.4.1 E-R&#x6A21;&#x578B;&#x7B80;&#x4ECB;</h3>
<p>E-R&#x6A21;&#x578B;&#x5373;E-R&#x56FE;&#x3002;</p>
<p>E-R&#x56FE;&#x5373;&#x5B9E;&#x4F53;-&#x8054;&#x7CFB;&#x56FE;(Entity Relationship Diagram)&#xFF0C;&#x662F;&#x6307;&#x63D0;&#x4F9B;&#x4E86;&#x8868;&#x793A;&#x5B9E;&#x4F53;&#x578B;&#x3001;&#x5C5E;&#x6027;&#x548C;&#x8054;&#x7CFB;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x7528;&#x6765;&#x63CF;&#x8FF0;&#x73B0;&#x5B9E;&#x4E16;&#x754C;&#x7684;&#x6982;&#x5FF5;&#x6A21;&#x578B;&#x3002;&#x7531;&#x7F8E;&#x7C4D;&#x534E;&#x88D4;&#x8BA1;&#x7B97;&#x673A;&#x79D1;&#x5B66;&#x5BB6;&#x9648;&#x54C1;&#x5C71;(Peter Chen)&#x53D1;&#x660E;&#x3002;</p>
<h3 id="342-er&#x6A21;&#x578B;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;">3.4.2 E-R&#x6A21;&#x578B;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;</h3>
<ul>
<li><p>&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93; &#x5173;&#x7CFB;&#x6A21;&#x578B;&#x7684;&#x57FA;&#x7840;&#x4E0A;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x6839;&#x636E;&#x4EA7;&#x54C1;&#x7ECF;&#x7406;&#x7684;&#x8BBE;&#x8BA1;&#x7B56;&#x5212;&#xFF0C;&#x62BD;&#x53D6;&#x51FA;&#x6765;&#x6A21;&#x578B;&#x4E0E;&#x5173;&#x7CFB;&#xFF0C;&#x5236;&#x5B9A;&#x51FA;&#x8868;&#x7ED3;&#x6784;&#xFF0C;&#x8FD9;&#x662F;&#x9879;&#x76EE;&#x5F00;&#x59CB;&#x7684;&#x7B2C;&#x4E00;&#x6B65;</p>
</li>
<li><p>&#x5728;&#x8BBE;&#x8BA1;&#x9636;&#x6BB5;&#x4E00;&#x822C;&#x4F7F;&#x7528;E-R&#x6A21;&#x578B;&#x8FDB;&#x884C;&#x5EFA;&#x6A21;&#x3002;&#x6709;&#x5F88;&#x591A;&#x8BBE;&#x8BA1;&#x6570;&#x636E;&#x5E93;&#x7684;&#x8F6F;&#x4EF6;&#xFF0C;&#x5E38;&#x7528;&#x7684;&#x5982;power designer&#xFF0C;db desinger&#x7B49;&#xFF0C;&#x8FD9;&#x4E9B;&#x8F6F;&#x4EF6;&#x53EF;&#x4EE5;&#x76F4;&#x89C2;&#x7684;&#x770B;&#x5230;&#x5B9E;&#x4F53;&#x53CA;&#x5B9E;&#x4F53;&#x95F4;&#x7684;&#x5173;&#x7CFB;</p>
</li>
<li><p>&#x8BBE;&#x8BA1;&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x53EF;&#x80FD;&#x662F;&#x7531;&#x4E13;&#x95E8;&#x7684;&#x6570;&#x636E;&#x5E93;&#x8BBE;&#x8BA1;&#x4EBA;&#x5458;&#x5B8C;&#x6210;&#xFF0C;&#x4E5F;&#x53EF;&#x80FD;&#x662F;&#x7531;&#x5F00;&#x53D1;&#x7EC4;&#x6210;&#x5458;&#x5B8C;&#x6210;&#xFF0C;&#x4E00;&#x822C;&#x662F;&#x9879;&#x76EE;&#x7ECF;&#x7406;&#x5E26;&#x9886;&#x7EC4;&#x5458;&#x6765;&#x5B8C;&#x6210;</p>
</li>
<li><p>&#x5F85;&#x8BBE;&#x8BA1;&#x5B8C;&#x6210;E-R&#x6A21;&#x578B;&#x4F1A;&#x5C06;&#x5176;&#x8F6C;&#x5316;&#x4E3A;&#x5173;&#x7CFB;&#x6A21;&#x578B;</p>
</li>
</ul>
<blockquote>
<p>&#x5173;&#x7CFB;&#x6A21;&#x578B; &#x7528;&#x4E8C;&#x7EF4;&#x8868;&#x7684;&#x5F62;&#x5F0F;&#x8868;&#x793A;&#x5B9E;&#x4F53;&#x548C;&#x5B9E;&#x4F53;&#x95F4;&#x8054;&#x7CFB;&#x7684;&#x6570;&#x636E;&#x6A21;&#x578B;</p>
<p>&#x73B0;&#x9636;&#x6BB5;&#x4E0D;&#x9700;&#x8981;&#x72EC;&#x7ACB;&#x5B8C;&#x6210;&#x6570;&#x636E;&#x5E93;&#x8BBE;&#x8BA1;&#xFF0C;&#x4F46;&#x662F;&#x8981;&#x6CE8;&#x610F;&#x79EF;&#x7D2F;&#x4E00;&#x4E9B;&#x8FD9;&#x65B9;&#x9762;&#x7684;&#x7ECF;&#x9A8C;</p>
</blockquote>
<h3 id="343-er&#x6A21;&#x578B;&#x7EC4;&#x6210;&#x5143;&#x7D20;">3.4.3 E-R&#x6A21;&#x578B;&#x7EC4;&#x6210;&#x5143;&#x7D20;</h3>
<p><img src="../assets/day16/E-R&#x56FE;&#x4E3E;&#x4F8B;.jpg" alt="">
E-R&#x56FE;&#x7528; &#x5B9E;&#x4F53;&#x3001;&#x8054;&#x7CFB;&#x548C;&#x5C5E;&#x6027;&#x8FD9;3&#x4E2A;&#x6982;&#x5FF5;&#x6765;&#x63CF;&#x8FF0;&#x73B0;&#x5B9E;&#x95EE;&#x9898;&#x3002; &#x6709;&#x4EE5;&#x4E0B;&#x4E09;&#x79CD;&#x5143;&#x7D20;:</p>
<ul>
<li><p>1 &#x5B9E;&#x4F53;&#x578B;(Entity)&#xFF1A;&#x5177;&#x6709;&#x76F8;&#x540C;&#x5C5E;&#x6027;&#x7684;&#x5B9E;&#x4F53;&#x5177;&#x6709;&#x76F8;&#x540C;&#x7684;&#x7279;&#x5F81;&#x548C;&#x6027;&#x8D28;&#xFF0C;&#x7528;&#x5B9E;&#x4F53;&#x540D;&#x53CA;&#x5176;&#x5C5E;&#x6027;&#x540D;&#x96C6;&#x5408;&#x6765;&#x62BD;&#x8C61;&#x548C;&#x523B;&#x753B;&#x540C;&#x7C7B;&#x5B9E;&#x4F53;;<strong>&#x5728;E-R&#x56FE;&#x4E2D;&#x7528;&#x77E9;&#x5F62;&#x8868;&#x793A;</strong>&#xFF0C;&#x77E9;&#x5F62;&#x6846;&#x5185;&#x5199;&#x660E;&#x5B9E;&#x4F53;&#x540D;&#xFF1B;&#x6BD4;&#x5982; &#x7535;&#x5546;&#x8D2D;&#x7269;&#x7CFB;&#x7EDF;&#x4E2D;&#x7528;&#x6237;&#x3001;&#x8D2D;&#x7269;&#x8F66;&#x3001;&#x8BA2;&#x5355;&#x7B49;&#x90FD;&#x662F;&#x5B9E;&#x4F53;&#x3002;</p>
</li>
<li><p>2 &#x5C5E;&#x6027;(Attribute)&#xFF1A;&#x5B9E;&#x4F53;&#x6240;&#x5177;&#x6709;&#x7684;&#x67D0;&#x4E00;&#x7279;&#x6027;&#xFF0C;&#x4E00;&#x4E2A;&#x5B9E;&#x4F53;&#x53EF;&#x7531;&#x82E5;&#x5E72;&#x4E2A;&#x5C5E;&#x6027;&#x6765;&#x523B;&#x753B;&#x3002;<strong>&#x5728;E-R&#x56FE;&#x4E2D;&#x7528;&#x692D;&#x5706;&#x5F62;&#x8868;&#x793A;</strong>&#xFF0C;&#x5E76;&#x7528;&#x65E0;&#x5411;&#x8FB9;&#x5C06;&#x5176;&#x4E0E;&#x76F8;&#x5E94;&#x7684;&#x5B9E;&#x4F53;&#x8FDE;&#x63A5;&#x8D77;&#x6765;&#xFF1B;&#x6BD4;&#x5982;&#x7528;&#x6237;&#x7684;ID&#x3001;&#x7528;&#x6237;&#x540D;&#x3001;&#x5BC6;&#x7801;&#x3001;&#x6635;&#x79F0;&#x3001;&#x8EAB;&#x4EFD;&#x8BC1;&#x53F7;&#x7801; &#x90FD;&#x662F;&#x5C5E;&#x6027;&#x3002;</p>
</li>
<li><p>3 &#x8054;&#x7CFB;(Relationship)&#xFF1A; &#x5B9E;&#x4F53;&#x5F7C;&#x6B64;&#x4E4B;&#x95F4;&#x76F8;&#x4E92;&#x8FDE;&#x63A5;&#x7684;&#x65B9;&#x5F0F;&#x79F0;&#x4E3A;&#x8054;&#x7CFB;&#xFF0C;&#x4E5F;&#x79F0;&#x4E3A;&#x5173;&#x7CFB;&#x3002;&#x8054;&#x7CFB;&#x53EF;&#x5206;&#x4E3A;&#x4EE5;&#x4E0B; 3 &#x79CD;&#x7C7B;&#x578B;&#xFF1A;</p>
<p>&#x4E00;&#x5BF9;&#x4E00;&#x3001;&#x4E00;&#x5BF9;&#x591A;&#x3001;&#x591A;&#x5BF9;&#x591A;</p>
</li>
<li>&#x5173;&#x7CFB;&#x4E5F;&#x662F;&#x4E00;&#x79CD;&#x6570;&#x636E;&#xFF0C;&#x9700;&#x8981;&#x901A;&#x8FC7;&#x4E00;&#x4E2A;&#x5B57;&#x6BB5;&#x5B58;&#x50A8;&#x5728;&#x8868;&#x4E2D;</li>
<li>&#x5B9E;&#x4F53;A&#x5BF9;&#x5B9E;&#x4F53;B&#x4E3A;1&#x5BF9;1&#xFF0C;&#x5219;&#x5728;&#x8868;A&#x6216;&#x8868;B&#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5B57;&#x6BB5;&#xFF0C;&#x5B58;&#x50A8;&#x53E6;&#x4E00;&#x4E2A;&#x8868;&#x7684;&#x4E3B;&#x952E;&#x503C;</li>
</ul>
<p><img src="../assets/day16/4-1.png" alt=""></p>
<ul>
<li>&#x5B9E;&#x4F53;A&#x5BF9;&#x5B9E;&#x4F53;B&#x4E3A;1&#x5BF9;&#x591A;&#xFF1A;&#x5728;&#x8868;B&#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5B57;&#x6BB5;&#xFF0C;&#x5B58;&#x50A8;&#x8868;A&#x7684;&#x4E3B;&#x952E;&#x503C;</li>
</ul>
<p><img src="../assets/day16/4-2.png" alt=""></p>
<ul>
<li>&#x5B9E;&#x4F53;A&#x5BF9;&#x5B9E;&#x4F53;B&#x4E3A;&#x591A;&#x5BF9;&#x591A;&#xFF1A;&#x65B0;&#x5EFA;&#x4E00;&#x5F20;&#x8868;C&#xFF0C;&#x8FD9;&#x4E2A;&#x8868;&#x53EA;&#x6709;&#x4E24;&#x4E2A;&#x5B57;&#x6BB5;&#xFF0C;&#x4E00;&#x4E2A;&#x7528;&#x4E8E;&#x5B58;&#x50A8;A&#x7684;&#x4E3B;&#x952E;&#x503C;&#xFF0C;&#x4E00;&#x4E2A;&#x7528;&#x4E8E;&#x5B58;&#x50A8;B&#x7684;&#x4E3B;&#x952E;&#x503C;</li>
</ul>
<p><img src="../assets/day16/4-3.png" alt=""></p>
<blockquote>
<ul>
<li>&#x60F3;&#x4E00;&#x60F3;&#xFF1A;&#x4E3E;&#x4E9B;&#x4F8B;&#x5B50;&#xFF0C;&#x6EE1;&#x8DB3;&#x4E00;&#x5BF9;&#x4E00;&#x3001;&#x4E00;&#x5BF9;&#x591A;&#x3001;&#x591A;&#x5BF9;&#x591A;&#x7684;&#x5BF9;&#x5E94;&#x5173;&#x7CFB;</li>
</ul>
<p>&#x6269;&#x5C55;&#x9605;&#x8BFB; {#&#x6269;&#x5C55;&#x9605;&#x8BFB;}</p>
<ul>
<li>&#x770B;&#x770B;&#x522B;&#x4EBA;&#x5BB6;&#x8BBE;&#x8BA1;&#x7684;&#x89C4;&#x8303; <a href="http://mp.weixin.qq.com/s/Yjh_fPgrjuhhOZyVtRQ-SA" target="_blank">58&#x5230;&#x5BB6;&#x6570;&#x636E;&#x5E93;30&#x6761;&#x519B;&#x89C4;&#x89E3;&#x8BFB;</a></li>
</ul>
</blockquote>
<h2 id="35-&#x603B;&#x7ED3;">3.5 &#x603B;&#x7ED3;</h2>
<ul>
<li><p>&#x8303;&#x5F0F;&#x5C31;&#x662F;&#x8BBE;&#x8BA1;&#x6570;&#x636E;&#x5E93;&#x7684;&#x901A;&#x7528;&#x89C4;&#x8303;&#x3002;</p>
<ul>
<li>1NF&#x5F3A;&#x8C03;&#x5B57;&#x6BB5;&#x662F;&#x6700;&#x5C0F;&#x5355;&#x5143;&#xFF0C;&#x4E0D;&#x53EF;&#x518D;&#x5206;</li>
<li>2NF&#x5F3A;&#x8C03;&#x5728;1NF&#x57FA;&#x7840;&#x4E0A;&#x5FC5;&#x987B;&#x8981;&#x6709;&#x4E3B;&#x952E;&#x548C;&#x975E;&#x4E3B;&#x952E;&#x5B57;&#x6BB5;&#x5FC5;&#x987B;&#x5B8C;&#x5168;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4; &#x4E0D;&#x80FD;&#x90E8;&#x5206;&#x4F9D;&#x8D56;</li>
<li>3MF&#x5F3A;&#x8C03;&#x5728;2NF&#x57FA;&#x7840;&#x4E0A; &#x975E;&#x4E3B;&#x952E;&#x5B57;&#x6BB5;&#x5FC5;&#x987B;&#x76F4;&#x63A5;&#x4F9D;&#x8D56;&#x4E8E;&#x4E3B;&#x952E;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x4E0D;&#x80FD;&#x4F20;&#x9012;&#x4F9D;&#x8D56;(&#x95F4;&#x63A5;&#x4F9D;&#x8D56;)&#x3002;</li>
</ul>
</li>
<li><p>E-R&#x56FE;&#x7531; &#x5B9E;&#x4F53;&#x3001;&#x5C5E;&#x6027;&#x3001;&#x5B9E;&#x4F53;&#x4E4B;&#x95F4;&#x7684;&#x8054;&#x7CFB;&#x6784;&#x6210;&#xFF0C;&#x4E3B;&#x8981;&#x7528;&#x6765;&#x63CF;&#x8FF0; &#x6570;&#x636E;&#x5E93;&#x4E2D;&#x8868;&#x7ED3;&#x6784;&#x3002;</p>
</li>
</ul>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../day16/sql_code.html" class="navigation navigation-prev " aria-label="Previous page: SQL演练"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../day16/pymysql.html" class="navigation navigation-next " aria-label="Next page: 数据库编程"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-splitter/splitter.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"toggle-chapters":{},"splitter":{},"emphasize":{},"highlight":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
    </body>
    <!-- End of book python高级 -->
</html>
